<!--
*Author：COCO
 *代码由框架生成,任何更改都可能导致被代码生成器覆盖
 *业务请在@/extension/warehouse/warehouse/View_StockBalance.js此处编写
 -->
<template>
    <view-grid ref="grid" :columns="columns" :detail="detail" :editFormFields="editFormFields"
        :editFormOptions="editFormOptions" :searchFormFields="searchFormFields" :searchFormOptions="searchFormOptions"
        :table="table" :extend="extend">
    </view-grid>
</template>
<script>
import extend from "@/extension/warehouse/warehouse/View_StockBalance.js";
import { ref, defineComponent } from "vue";
export default defineComponent({
    setup() {
        const table = ref({
            key: 'Product_Id',
            footer: "Foots",
            cnName: '库存',
            name: 'warehouse/View_StockBalance',
            url: "/InventoryStock/",
            sortName: "CreateDate"
        });
        const editFormFields = ref({});
        const editFormOptions = ref([]);
        const searchFormFields = ref({
            "WareHouseCode": "",
            "WareHouseName": "",
            "InventoryCode": "",
            "InventoryName": "",
            "AvailableQuantity": "",
            "ExistingQuantity": "",
            "ProductionDate": "",
            "ExpiryDate": ""
        });

        const searchFormOptions = ref([
            [
                { "title": "库存编码", "field": "WareHouseCode", "type": "like" },
                { "title": "库存名称", "field": "WareHouseName", "type": "like" },
            ],
            [
                { "title": "存货编码", "field": "InventoryCode", "type": "like" },
                { "dataKey": "存货名称", "field": "InventoryName", "type": "like" }
            ],
            [
                { "title": "可用库存", "field": "AvailableQuantity", "type": "number" },
                { "title": "现有库存", "field": "ExistingQuantity", "type": "number" }
            ],
            [
                { "title": "生产日期", "field": "ProductionDate", "type": "datetime" },
                { "title": "有效期", "field": "ExpiryDate", "type": "datetime" }
            ]
        ]);
        const columns = ref(
            [
                { field: 'wareHouseCode', title: '仓库编码', type: 'string', width: 100, require: true, align: 'left', sort: true },
                { field: 'wareHouseName', title: '仓库名称', type: 'string', sort: true, width: 150, require: true, align: 'left' },
                { field: 'inventoryCode', title: '存货编码', type: 'string', sort: true, width: 100, align: 'left' },
                { field: 'inventoryName', title: '存货名称', type: 'string', sort: true, width: 150, align: 'left' },
                { field: 'availableQuantity', title: '可用库存', type: 'number',  width: 50, require: true, align: 'left' },
                { field: 'existingQuantity', title: '现有库存', type: 'number',  width: 50, align: 'left' },
                {
                    field: 'productionDate', title: '生产日期', type: 'datetime', sort: true, width: 110, align: 'left', templet: function (d) {
                        return d.productionDate
                            ? d.productionDate
                            : '<span style="color:red;">null</span>';
                    }
                },
                {
                    field: 'expiryDate', title: '有效期', type: 'datetime', sort: true, width: 110, align: 'left', templet: function (d) {
                        return d.expiryDate
                            ? d.expiryDate
                            : '<span style="color:red;">null</span>';
                    }
                },
            ]);
        const detail = ref({
            cnName: "#detailCnName",
            table: "#detailTable",
            columns: [],
            sortName: "",
            key: ""
        });
        return {
            table,
            extend,
            editFormFields,
            editFormOptions,
            searchFormFields,
            searchFormOptions,
            columns,
            detail,
        };
    },
});
</script>
